#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''eof
name:已结清不良信贷笔数
code:SettledLoansNum_of_Non_performing
tableName:
columnName:
groups:企业征信
dependencies:EC
type:常用指标
dataSourceType:在线指标
description:
eof'''

'''
ECRSummarySettled02:已结清信贷信息概要（7类信贷业务）
LoanBadsumNumber:贷款不良类笔数

'''

import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

def SettledLoansNum_of_Non_performing():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/']
    try:
        if EC.has_key('ECRSummarySettled02') and len(EC['ECRSummarySettled02']) == 1:
            if EC['ECRSummarySettled02'][0].has_key('LoanBadsumNumber') \
                and EC['ECRSummarySettled02'][0]['LoanBadsumNumber'] not in null_type_list:
                num = EC['ECRSummarySettled02'][0]['LoanBadsumNumber']
                return float(num)
            else:
                return 0
        else:
            return u'缺失值'
    except:
        return u'缺失值'

result = SettledLoansNum_of_Non_performing()